package com.example.administrator.yuejian35.Home.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian35.BaseListAdapter;
import com.example.administrator.yuejian35.Home.activity.ActivitysActivity;
import com.example.administrator.yuejian35.Home.bean.Activity;
import com.example.administrator.yuejian35.R;

import java.util.List;

/**
 * Created by Wolfh on 2017/4/29.
 */

public class ActivityAdapter extends BaseListAdapter {

    public ActivityAdapter(Context context, List list){
        super(context, list);

    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View ItemView = layoutInflater.inflate(R.layout.item_activity,parent,false);

        ActivityViewHolder viewHolder = new ActivityViewHolder(ItemView);//定义显示部件

        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, int position, List data) {
        final Activity activitys = (Activity) data.get(position);

        if(holder instanceof  ActivityViewHolder){

            ActivityViewHolder viewHolder = (ActivityViewHolder) holder;
           String apply = String.valueOf(activitys.getPsum());

            viewHolder.name.setText(activitys.getAname());
            viewHolder.time.setText(activitys.getTime());
            viewHolder.price.setText(activitys.getAmoney());
            viewHolder.collect.setText(activitys.getCollect());
            viewHolder.apply.setText(String.valueOf(activitys.getPsum()));
            viewHolder.address.setText("活动地址："+ activitys.getAddress());
            viewHolder.tel.setText("活动热线："+ activitys.getTel());


            //final int aid = Integer.parseInt(activitys.getAid());

            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    //启动新的Activity - 店铺详情（菜品列表）

                    Intent intent = new Intent(context, ActivitysActivity.class);

                    intent.putExtra("activitys", activitys);

                    context.startActivity(intent);

                }
            });



        }
    }


}
